// pages/index/departmentIntroduce/departmentIntroduce.js
var t = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    famous: [{
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 1,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 1,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      },
      {
        img: '/assets/images/wei.jpg',
        name: '小花',
        state: 0,
        department: '骨科',
        title: '主治医师',
        where: '山西大医院',
        people: '10',
        branch: '5',
        introduce: '专业接骨20年'
      }
    ]
  },
  open: function() {
    t.data.whichPage = 0;
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let a = this.data.famous;
    var nksid = options.nksid
    this.setData({
      nksid: nksid
    })
    for (let i = 0; i < a.length; i++) {
      if (a[i].introduce.length > 30) {
        a[i].introduce = a[i].introduce.substring(0, 30) + '...'
      }
    }
    this.getAllkeshidoc()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  getAllkeshidoc: function() {
    var that = this
    var nksid = that.data.nksid
    t.util.request({
      'url': 'entry/wxapp/address',
      data: {
        op: 'keshidoc',
        nksid: nksid
      },
      success: function (res) {
        console.log(res)
        that.setData({
          keshidoc: res.data
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  }
})